<template>
  <div>
    <header>
      <van-row type="flex" justify="space-between">
        <van-col span="8">
          <router-link to="/layout/Mine">
            <van-icon name="arrow-left" />
          </router-link>
        </van-col>
        <van-col span="8">修改个人信息</van-col>
        <van-col span="8"></van-col>
      </van-row>
    </header>
    <div class="reset">
      <van-form @submit="onSubmit">
        <van-field
          v-model="username"
          name="昵称"
          label="昵称"
          placeholder="请修改昵称"
          :rules="[{ required: true, message: '请填写用户名' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="密码"
          label="密码"
          placeholder="请填写密码"
          :rules="[{ required: true, message: '请填写新密码' }]"
        />
        <div style="margin-top: 50px">
          <van-button round block type="info" native-type="submit"
            >提交</van-button
          >
        </div>
      </van-form>
    </div>
    <!-- 底部 -->
  </div>
</template>
<script>
import { resetInfo } from "../api/api";
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    onSubmit() {
      resetInfo(this.username, this.password).then((res) => {
        // console.log(res);
        if (res.code == 0) {
          this.$notify({ type: "success", message: "修改成功,请重新登录" });
          this.$router.push("/login");
        }
      });
    },
  },
};
</script>
<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
header {
  width: 100%;
  height: 50px;
  line-height: 50px;
  background-color: #eee;
}
.reset {
  width: 100%;
  padding: 20px;
  box-sizing: border-box;
  margin-top: 50px;
  .van-cell {
    margin-top: 30px;
  }
}
</style>